//
//  AboutUSViewController.m
//  网络FM
//
//  Created by dlios on 15/5/29.
//  Copyright (c) 2015年 dengzhicheng.com. All rights reserved.
//

#import "AboutUSViewController.h"
#define HEIGHT [[UIScreen mainScreen] bounds].size.height
 
@interface AboutUSViewController ()

@property (nonatomic, retain) UILabel *label;

@end

@implementation AboutUSViewController


- (void)dealloc
{
    [_label release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    UISwipeGestureRecognizer * recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    
    [self.view addGestureRecognizer:recognizer];
    
    [recognizer release];
    
    [self createView];
}

-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
    
    
    //如果往右滑
    
    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
}


- (void)createView
{
    NSString *str = @"关于我们\n   星空FM网络电台：星空FM网络电台成立于2015年5月23日,是专门为喜爱电台的人而设计的。 为广大听众提供专业的娱乐，了解实时动态，资金借贷等方面的服务性应用。星空FM网络电台用先进的理念创建，简化了操作，让广大听众改善收听体验。星空FM网络电台相信，我们优质的服务以及及时的更新一定能获得您的青睐。\n 团队介绍：我们团队成员都来于App编程爱好者，互相都彼此了解，信任。团队里都是充满激情的年轻奋斗者，有奋斗激情和远大梦想。我们是一支执行力高效的精干团队，具有拼搏的精神，成功的决心和信念，以及坚持的恒心。\n服务对象:广大听众\n服务宗旨：全心全意为听众朋友提供优质服务\n\n联系我们\n客户服务:如果你在使用过程中有什么疑问可以与我们的客服人员进行联系。\n客服群：421811378\n客服邮箱：420385517@qq.com";
    
    if (HEIGHT == 480) {
        [self createUsLabel:str size:12];
    } else if (HEIGHT == 568)
    {
        [self createUsLabel:str size:13];
    } else if (HEIGHT == 667)
    {
        [self createUsLabel:str size:16];
    } else
    {
        [self createUsLabel:str size:18];
    }
    
    

    
    
    UILabel *copyright = [[UILabel alloc]initWithFrame:CGRectMake(0 ,30 ,self.view.frame.size.width,30)];
    copyright.text = @"关于我们";
    copyright.textAlignment = NSTextAlignmentCenter;
    copyright.font = [UIFont boldSystemFontOfSize:20];
    
    [self.view addSubview:copyright];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 1)];
    [view setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:view];
    [view release];
    
    
    UIImageView *ima = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    [ima setCenter:CGPointMake(self.view.frame.size.width / 2 - 80, self.view.frame.size.height / 8  * 7 + 20)];
    [ima setBackgroundColor:[UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1.0f]];
    ima.image = [UIImage imageNamed:@"占位图.jpg"];
    ima.layer.cornerRadius = 5;
    ima.clipsToBounds = YES;
    
    
    UILabel *footer = [[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 2 - 50, self.view.frame.size.height / 8 * 7, 80, 20)];
    
    [self.view addSubview:footer];
    footer.text = @"星空FM";
    [footer setFont:[UIFont systemFontOfSize:12]];
    footer.textAlignment = NSTextAlignmentCenter;
    
    
    UILabel *type = [[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 2 - 50, self.view.frame.size.height / 8 * 7 + 20, 80, 20)];
    
    [self.view addSubview:type];
    type.text = @"IOS v1.0";
    [type  setFont: [UIFont systemFontOfSize:12]];
    type.textAlignment = NSTextAlignmentCenter;
    
    
    
    [self.view addSubview:ima];
    
    
    
    
    
    
    [copyright release];
    
    
    //    UIGestureRecognizer *gesture = [[UIGestureRecognizer alloc]initWithTarget:self action:@selector(back:)];
    //    [self.view addGestureRecognizer:gesture];
    
    
    
    
}


- (void)createUsLabel:(NSString *)str size:(NSInteger)size
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:size]};
    CGRect rect = [str boundingRectWithSize:CGSizeMake(self.view.frame.size.width - 60, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(30, 80, self.view.frame.size.width - 60, rect.size.height)];
    self.label.text = str;
    self.label.numberOfLines = 0;
    self.label.textColor = [UIColor blackColor];
    [self.label setFont:[UIFont systemFontOfSize:size]];
    [self.label setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:_label];
    [_label release];
}

@end
